    .MODEL SMALL
    .STACK 100h

    .DATA
    CONST1 DW 0
    CONST2 DW 1
    i DW ?    ; local int
    N DW ?    ; local int
    sum DW ?    ; local int
    t3 DW ?
    t4 DW ?
    t5 DW ?

    .CODE

PRINT_NUMBER PROC
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    MOV CX,0
    MOV BX,10
    CMP AX,0
    JNE _PN_LOOP
    MOV DL,'0'
    MOV AH,02h
    INT 21h
    JMP _PN_DONE
_PN_LOOP:
    XOR DX,DX
    DIV BX
    PUSH DX
    INC CX
    CMP AX,0
    JNE _PN_LOOP
_PN_OUT:
    POP DX
    ADD DL,'0'
    MOV AH,02h
    INT 21h
    LOOP _PN_OUT
_PN_DONE:
    POP DX
    POP CX
    POP BX
    POP AX
    RET
PRINT_NUMBER ENDP
SCANF_NUMBER PROC
    PUSH BX
    PUSH CX
    PUSH DX
    MOV DX, 0
    MOV CX, 0
    MOV BX, 10
_READ_CHAR:
    MOV AH, 01h
    INT 21h
    CMP AL, 0DH
    JE  _END_INPUT
    CMP AL, '0'
    JL  _END_INPUT
    CMP AL, '9'
    JG  _END_INPUT
    MOV AH, 0
    SUB AL, '0'
    MOV CX, AX
    MOV AX, DX
    MUL BX
    MOV DX, AX
    MOV AX, CX
    ADD DX, AX
    JMP _READ_CHAR
_END_INPUT:
    MOV AX, DX
    POP DX
    POP CX
    POP BX
    RET
SCANF_NUMBER ENDP


MAIN PROC
    MOV AX,@DATA
    MOV DS,AX

    MOV AX, 0
    MOV sum, AX
    CALL SCANF_NUMBER
    MOV N, AX
    MOV AX, 1
    MOV i, AX
Lt1:
    MOV AX,i
    CMP AX,N
    MOV t3,0
    JLE REL_TRUE_1
    JMP REL_END_2
REL_TRUE_1:
    MOV t3,1
REL_END_2:
    MOV AX, t3
    CMP AX, 0
    JNE SHORT JZ_SKIP_3
    JMP Lt2
JZ_SKIP_3:
    MOV AX, sum
    ADD AX, i
    MOV t4, AX
    MOV AX, t4
    MOV sum, AX
    MOV AX, i
    ADD AX, CONST2
    MOV t5, AX
    MOV AX, t5
    MOV i, AX
    JMP Lt1
Lt2:
    MOV AX, sum
    CALL PRINT_NUMBER

    MOV AH,4Ch
    INT 21h
MAIN ENDP
    END MAIN